package com.xbongbong.sys.model.impl;

import com.xbongbong.sys.domain.dao.WeakManageDao;
import com.xbongbong.sys.domain.entity.WeakManageEntity;
import com.xbongbong.sys.model.WeakManageModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 *
 * @author kaka
 * @date 2019/2/13 14:20
 * @since v1.0
 * @version v1.0
 */
@Service("weakManageModel")
public class WeakManageModelImpl implements WeakManageModel {

    @Resource
    private WeakManageDao dao;

    @Override
    public Integer insert(WeakManageEntity entity) {
        entity.setId(null);
        return dao.insert(entity);
    }

    @Override
    public void insertBatch(List<WeakManageEntity> list) {
        dao.insertBatch(list);
    }

    @Override
    public Integer update(WeakManageEntity entity) {
        return dao.update(entity);
    }

    @Override
    public Integer save(WeakManageEntity entity) {
        if(entity.getId() == null || Objects.equals(0, entity.getId())) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public Integer deleteByKey(Integer key, String corpid) {
        return dao.deleteByKey(key, corpid);
    }

    @Override
    public Integer physicalDeleteBySupId(String corpid, String supUserId) {
        return dao.physicalDeleteBySupId(corpid, supUserId);
    }


    @Override
    public WeakManageEntity getByKey(Integer key, String corpid) {
        return dao.getByKey(key, corpid);
    }

    @Override
    public List<WeakManageEntity> findEntitys(Map<String, Object> param) {
        return dao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return dao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
}
